#ifndef  _SERVER_H_
#define  _SERVER_H_

#include "../define/define.h"
#include "node_list.h"
#include "../util/log.h"
#include "../util/lock.h"

class server 
{
public:	
    server()
	{
		func_lock locker;

		m_log = new logfile("server");

		m_node_list = new Node_list();
	}

	~server()
	{
		func_lock locker;
		m_log->WriteTrace("delete server");
		delete m_log;
		delete m_node_list;
	}

    bool init(UDPServer* udp, uint32 socket,uint32 d_socket,uint8 cmd)
	{
		m_node_list->init(udp,socket,d_socket,cmd);
		return true;
	}
	
	bool add_node(ip_node node)
	{
		return m_node_list->add_node(node);
	}

	bool free()
	{
        m_node_list->free();
		return true;
	}

	bool set_d_socket(uint32 d_socket)
	{
		return m_node_list->set_d_socket(d_socket); 
	}

	bool set_big_id()
	{
		return m_node_list->set_over();
	}

	bool add_trans(ip_node node,Link_info trans,uint32 con_id)
	{
		return m_node_list->add_trans(node,trans,con_id);
	}

	bool send_down_over()
	{
		return m_node_list->send_down_over();
	}

	bool ack_data(uint32 con_id,uint32 socket, char* buf, uint32 buf_size)
	{
		func_lock locker;

		return m_node_list->ack_data(socket,con_id,buf,buf_size);	
	}

	bool Put_data(char* buf, uint32 buf_size)
	{
		func_lock locker;
		return m_node_list->put_data(buf,buf_size);
	}

	bool is_full()
	{
		return m_node_list->is_full();
	}

private:
		
	Node_list*  m_node_list;
	UDPServer*  m_udp;

	uint32      m_socket;
	logfile*    m_log;

	uint8       m_pdu;
};


#endif